home *** CD-ROM | disk | FTP | other *** search
- /*
- APL2C_C.C - APL to C functions
- Support for APL2PC to C interface
-
- */
-
- #include "apl2c_h.h"
-
- /*
- APL_VHDR - load in APL Variable Header info to C struct
- */
- void apl_vhdr(struct aplvhdr * aplvar)
- {
- int ptr;
-
- ptr = aplvar->ptr; /* move bytes 2 thru 8 */
- mov_mem( (char far *) &aplvar->nb,MK_FP(ptr,2),6);
-
- if(aplvar->rank) /* if non zero rank, move dimensions */
- mov_mem( (char far *)aplvar->dimens,MK_FP(ptr,8),aplvar->rank * 2);
- }
-
- /*
- VHDR_APL - load (C struct) Variable Header to APL
- */
- void vhdr_apl(struct aplvhdr * aplvar)
- {
- int ptr;
-
- ptr = aplvar->ptr; /* move bytes 2 thru 8 */
- mov_mem(MK_FP(ptr,2),(char far *) &aplvar->nb,6);
-
- if(aplvar->rank) /* if non zero rank, move dimensions */
- mov_mem(MK_FP(ptr,8),(char far *)aplvar->dimens,aplvar->rank * 2);
- }
-
-
- /*
- APL_VFDATA - load in APL Variable DATA
- NOTE !! - bufr MUST be large enough
- to hold data ...
- */
- void apl_vfdata(struct aplvhdr * aplvar,char far * bufr)
- {
- int offset,count,bpe;
-
- if(aplvar->type == 3) /* char = 1 */
- bpe = 1;
- else if(aplvar->type == 2) /* real = 8 */
- bpe = 8;
- else /* ints,2byte char, etc */
- bpe = 2;
-
- offset = 8 + aplvar->rank * 2; /* where data starts */
- count = aplvar->nelm * bpe;
- mov_mem( (char far *)bufr,MK_FP(aplvar->ptr,offset),count);
- }
-
- /*
- PEEK - fetch a WORD from memory from SEG:OFF
- */
- int peek(int seg,int off)
- {
- return *(int far *) MK_FP(seg,off);
- }
-
- /*
- POKE - put a WORD into memory at SEG:OFF
- */
- void poke(int seg,int off,int word)
- {
- *( (int far *)MK_FP(seg,off) ) = word;
- }
-
- /*
- NOV_MEM - move block of data from one mem location to another
- */
- void mov_mem(char far * dest,char far * srce,int count)
- {
- while(count --)
- *dest++ = *srce++;
- }